#include "mycombobox.h"
#include "global.h"


MyCombobox::MyCombobox(QWidget *parent) : QComboBox(parent)
{

}

void MyCombobox::setComboBoxStyle(MyCombobox *pComBox, QFont font, QList<QString> stringList, QString styleSheet)
{
    if(NULL == pComBox){
        QLOG_WARN() << "NULL == pComBox";
        return ;
    }

    QListWidget *listWidget = new QListWidget(this);
    for(int i = 0;i < stringList.count();++i) {
        QListWidgetItem *item = new QListWidgetItem(stringList.at(i));
        item->setFont(font);
        item->setTextAlignment(Qt::AlignCenter);
        listWidget->addItem(item);
    }

    pComBox->setModel(listWidget->model());
    pComBox->setView(listWidget);

    QLineEdit *lineEdit = new QLineEdit;
    lineEdit->setReadOnly(true);
    lineEdit->setAlignment(Qt::AlignCenter);
    lineEdit->setFont(font);

    pComBox->setLineEdit(lineEdit);
    pComBox->setStyleSheet(styleSheet);

    return;
}
